import pymysql

if __name__ == '__main__':
    try:
        conn = pymysql.Connect(host = '10.170.129.6',
                                     port = 3306,
                                     user = 'root',
                                     passwd = '123456',
                                     db = 'shp',
                                     charset='utf8mb4')
        cur = conn.cursor()

    except:
        cur.close()
        conn.close()